#pragma once

#include "stdafx.h"

class CQuadTree
{
	enum CornerType{ BOTTOM_LEFT, BOTTOM_RIGHT ,TOP_LEFT , TOP_RIGHT };

public:
	CQuadTree(int cx,int cy);
	CQuadTree(int nCornerBL,int nCornerBR,int nCornerTL,int nCornerTR);
	~CQuadTree();
public:
	bool		Build();
	bool		Divide();
	int			GenTriIndex(LPVOID pIndex,int nTriangles=0);

private:
	CQuadTree*		m_pChild[4];

	int				m_nCenter;
	int				m_nCorner[4];
private:
	bool		SetCorners(int nCornerBL,int nCornerBR,int nCornerTL,int nCornerTR);
	bool		IsVisible()		{	return m_nCorner[BOTTOM_RIGHT] - m_nCorner[BOTTOM_LEFT] <= 1 ; }

};
